import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
import { tap, delay } from 'rxjs/operators';
import { WindowService } from '@core/services/common/window.service';
import { Router } from '@angular/router';
import { AuthService } from '@core/services/common/auth.service';

@Injectable({
  providedIn: 'root',
})
export class LoginInOutService {

  constructor(
    private windowServe: WindowService,
    private router: Router,
    private authService: AuthService
  ) {}

  login(token: string): void {
    this.authService.setAuthorizationToken(token);
  }

  logout(): void {
    this.windowServe.clearSessionStorage();
    this.windowServe.clearStorage();
    this.router.navigateByUrl('/login');
  }
}
